home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Express Pd: GALORE
/
Express Pd Galore - The Amiga PD & Shareware CD (1994)(Express Pd)[!][Amiga-CD32-CDTV].iso
/
amicus
/
amicus_#5
/
printer
/
printer.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-01-03
|
3KB
|
95 lines
/* printer.c - program to do a raster dump to whatever printer is specified
* by Preferences, of the Workbench Screen.
*
* Author: Rob Peck, 12/1/85
*
* This code may be freely utilized to develop programs for the Amiga */
*/
#include "exec/types.h"
#include "intuition/intuition.h"
#include "devices/printer.h"
#define INTUITION_WONT_OPEN 1000
union printerIO {
struct IOStdReq ios;
struct IODRPReq iodrp;
struct IOPrtCmdReq iopc;
};
union printerIO *request; /* a pointer to a request block */
extern int DumpRPort();
extern struct IORequest *CreateExtIO();
extern struct Window *OpenWindow();
extern struct Port *CreatePort();
struct IntuitionBase *IntuitionBase;
struct NewWindow nw = {
0, 0, 100, 40, 0, 1, 0, 0, NULL, NULL, NULL, NULL, NULL,
0, 0, 0, 0, WBENCHSCREEN
};
main()
{
struct Window *w;
struct Screen *screen;
struct RastPort *rp;
struct ViewPort *vp;
struct ColorMap *cm;
union printerIO sizeDummy;
int modes,width,height,error;
struct Port *printerPort; /* at which to receive reply */
IntuitionBase = (struct IntuitionBase *)OpenLibrary(
"intuition.library", 0);
if (IntuitionBase == NULL) exit(INTUITION_WONT_OPEN);
w = OpenWindow(&nw);
if(w == NULL) goto cleanup1;
screen = w->WScreen; /* get screen address from window */
CloseWindow(w); /* once have screen address, no
* more need for window, close it.
*/
vp = &screen->ViewPort; /* get screen's ViewPort, from
* which the colormap will be gotten */
rp = &screen->RastPort; /* get screen's RastPort, which
* is what gets dumped to printer */
cm = vp->ColorMap; /* retrieve pointer to colormap for
* the printer dump */
modes = vp->Modes; /* retrieve the modes variable */
width = vp->DWidth; /* retrieve width to print */
height = vp->DHeight; /* retrieve height to print */
printerPort = CreatePort("my.print.port",0);
request = (union printerIO *)CreateExtIO(printerPort,
sizeof(sizeDummy));
error = OpenPrinter(request);
if(error != 0) goto cleanup2;
Delay(300); /* 300/60 = 6 seconds delay before it starts */
error = DumpRPort(
request,/* pointer to initialized request */
rp, /* rastport pointer */
cm, /* color map pointer */
modes, /* low, high res, etc (display modes)*/
0, 0, /* x and y offsets into rastport */
width,height, /* source size */
width,(height * 2), /* dest rows, columns */
SPECIAL_FULLROWS
| SPECIAL_FULLCOLS
| SPECIAL_ASPECT /* io Special value, says print
* as pixels only, direct copy */
);
ClosePrinter(request);
cleanup2:
DeleteExtIO(request, sizeof(sizeDummy));
DeletePort(printerPort);
cleanup1:
CloseLibrary(IntuitionBase);
} /* end of demo screen dump */